<html><head><title>Specify a Penalised Beta (Regression) Spline Fit in a GAMLSS Formula</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="Rchm.css">
</head>
<body>

<table width="100%"><tr><td>ps(gamlss)</td><td align="right">R Documentation</td></tr></table><object type="application/x-oleobject" classid="clsid:1e2a7bd0-dab9-11d0-b93a-00c04fc99f9e">
<param name="keyword" value="R:   ps">
<param name="keyword" value="R:   pb">
<param name="keyword" value="R:   pb.control">
<param name="keyword" value="R:   cy">
<param name="keyword" value="R:   cy.control">
<param name="keyword" value=" Specify a Penalised Beta (Regression) Spline Fit in a GAMLSS Formula">
</object>


<h2>Specify a Penalised Beta (Regression) Spline Fit in a GAMLSS Formula</h2>


<h3>Description</h3>

<p>
There are several function operating penalised B-splines: <code>pb()</code>,  <code>cy()</code>, and <code>ps()</code>.
The functions take a vector and return it with several attributes. 
The vector is used in the construction of the design matrix X used in the fitting.  The functions  do not do the  smoothing, 
but assign the attributes to the vector to aid gamlss in the smoothing. 
The functions doing the smoothing are  <code><a href="gamlss.ps.html">gamlss.ps</a>()</code> <code><a href="gamlss.ps.html">gamlss.pb</a>()</code> and <code><a href="gamlss.ps.html">gamlss.cy</a>()</code> which are used in 
the backfitting  function <code><a href="additive.fit.html">additive.fit</a></code>.
The function <code>pb()</code> is more efficient and faster than the original
penalized smoothing function <code>ps()</code>. 
<code>pb()</code> allows the estimation of the smoothing parameters using different local (performance iterations) methods.
The method are "ML", "ML-1", "EM", "GAIC" and "GCV".
The function <code>cy()</code> fits a cycle penalised beta regression spline such as the last fitted value of the smoother is equal to 
the first fitted value.
</p>


<h3>Usage</h3>

<pre>
pb(x, df = NULL, lambda = NULL, control = pb.control(...), ...)
pb.control(inter = 20, degree = 3, order = 2, start = 10, quantiles = FALSE, 
               method = c("ML", "GAIC", "GCV", "EM", "ML-1"), k = 2, ...)
cy(x, df = NULL, lambda = NULL, control = cy.control(...), ...)
cy.control(inter = 20, degree = 3, order = 2, start = 10, 
          method = c("ML", "GAIC", "GCV", "EM", "ML-1"), k = 2, ts=FALSE, ...)
ps(x, df = 3, lambda = NULL, ps.intervals = 20, degree = 3, order = 3)
</pre>


<h3>Arguments</h3>

<table summary="R argblock">
<tr valign="top"><td><code>x</code></td>
<td>
the univariate predictor</td></tr>
<tr valign="top"><td><code>df</code></td>
<td>
the desired equivalent number of degrees of freedom (trace of the smoother matrix minus two for the constant and linear fit)</td></tr>
<tr valign="top"><td><code>lambda</code></td>
<td>
the smoothing parameter</td></tr>
<tr valign="top"><td><code>control</code></td>
<td>
setting the control parameters</td></tr>
<tr valign="top"><td><code>...</code></td>
<td>
for extra arguments</td></tr>
<tr valign="top"><td><code>inter</code></td>
<td>
the no of break points (knots) in the x-axis</td></tr>
<tr valign="top"><td><code>degree</code></td>
<td>
the degree of the piecewise polynomial</td></tr>
<tr valign="top"><td><code>order</code></td>
<td>
the required difference in the vector of coefficients</td></tr>
<tr valign="top"><td><code>start</code></td>
<td>
the lambda starting value if the local methods are used, see below</td></tr>
<tr valign="top"><td><code>quantiles</code></td>
<td>
if TRUE the quantile values of x are use to determine the knots</td></tr>
<tr valign="top"><td><code>ts</code></td>
<td>
if TRUE assumes that it is a seasonal factor</td></tr>
<tr valign="top"><td><code>method</code></td>
<td>
The method used in the (local) performance iterations. Available methods are "ML", "ML-1", "EM", "GAIC" and "GCV"</td></tr>
<tr valign="top"><td><code>k</code></td>
<td>
the penalty used in "GAIC" and "GCV"</td></tr>
<tr valign="top"><td><code>ps.intervals</code></td>
<td>
the no of break points in the x-axis</td></tr>
</table>

<h3>Details</h3>

<p>
The <code>ps()</code> function is based on Brian Marx function which can be found in <a href="http://www.stat.lsu.edu/faculty/marx/">http://www.stat.lsu.edu/faculty/marx/</a>.
The <code>pb()</code> and <code>cy()</code> functions are based on Paul Eilers original R functions. 
Note that  <code>ps()</code> and  <code>pb()</code> functions behave differently at their default values if df and lambda are not specified.
<code>ps(x)</code> by default will use 3 extra degrees of freedom for smoothing <code>x</code>.
<code>pb(x)</code> by default will estimate lambda (and the degrees of freedom) automatically using a local method.
Local (or performance iterations) methods available are (i) Maximum Likelihood, "ML", (ii) Generalized Akaike information criterion, "GAIC"
(iii) Generalized Cross validation. (iv) EM-algorithm, "EM" (very slow) and (v) a modified version of the ML, "ML-1" which produce identical 
results with "EM" but faster.  
Note that if the local  (or performance iterations) methods can be  make the convergence of gamlss less stable
compared to a model where the degrees of freedom are fixed.
</p>


<h3>Value</h3>

<p>
the vector x is returned, endowed with a number of attributes. The vector itself is used in the construction of the model matrix, 
while the attributes are needed for the backfitting algorithms <code>additive.fit()</code>.</p>

<h3>Author(s)</h3>

<p>
Mikis Stasinopoulos <a href="mailto:d.stasinopoulos@londonmet.ac.uk">d.stasinopoulos@londonmet.ac.uk</a>, Bob Rigby <a href="mailto:r.rigby@londonmet.ac.uk ">r.rigby@londonmet.ac.uk </a> and Paul Eilers
</p>


<h3>References</h3>

<p>
<a href="http://www.stat.lsu.edu/faculty/marx/">http://www.stat.lsu.edu/faculty/marx/</a> 
</p>
<p>
Eilers, P. H. C. and Marx, B. D. (1996). Flexible smoothing with
B-splines and penalties (with comments and rejoinder). <EM>Statist. Sci</EM>,
<B>11</B>, 89-121.
</p>
<p>
Rigby, R. A. and  Stasinopoulos D. M. (2005). Generalized additive models for location, scale and shape,(with discussion), 
<EM>Appl. Statist.</EM>, <B>54</B>, part 3, pp 507-554.
</p>
<p>
Stasinopoulos D. M. Rigby R.A. (2007) Generalized additive models for location scale and shape (GAMLSS) in R.
<EM>Journal of Statistical Software</EM>, Vol. <B>23</B>, Issue 7, Dec 2007, <a href="http://www.jstatsoft.org/v23/i07">http://www.jstatsoft.org/v23/i07</a>.
</p>


<h3>See Also</h3>

<p>
<code><a href="gamlss.html">gamlss</a></code>, <code><a href="gamlss.ps.html">gamlss.ps</a></code>, <code><a href="cs.html">cs</a></code>
</p>


<h3>Examples</h3>

<pre>
data(aids)
# fitting a smoothing cubic spline with 7 degrees of freedom
# plus the a quarterly  effect  
aids1&lt;-gamlss(y~ps(x,df=7)+qrt,data=aids,family=PO) # 
aids2&lt;-gamlss(y~pb(x,df=7)+qrt,data=aids,family=PO) # 
aids3&lt;-gamlss(y~pb(x)+qrt,data=aids,family=PO) #
with(aids, plot(x,y))
with(aids, lines(x,fitted(aids1),col="red"))
with(aids, lines(x,fitted(aids2),col="green"))
with(aids, lines(x,fitted(aids1),col="yellow"))
rm(aids1, aids2, aids3)
# simulate data
set.seed(555)
x = seq(0, 1, length = 100)
y = sign(cos(1 * x * 2 * pi + pi / 4)) + rnorm(length(x)) * 0.2
plot(y~x)
m1&lt;-gamlss(y~cy(x))
lines(fitted(m1)~x)
rm(y,x,m1)
</pre>



<hr><div align="center">[Package <em>gamlss</em> version 3.0-1 <a href="00Index.html">Index</a>]</div>

</body></html>
